package com.dyrj.component.datasoure;//package com.dyrj.component.datasoure;
//
//import org.apache.ibatis.session.SqlSessionFactory;
//import org.mybatis.spring.SqlSessionFactoryBean;
//import org.mybatis.spring.SqlSessionTemplate;
//import org.mybatis.spring.annotation.MapperScan;
//import org.springframework.beans.factory.annotation.Qualifier;
//import org.springframework.boot.context.properties.ConfigurationProperties;
//import org.springframework.boot.jdbc.DataSourceBuilder;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
//import org.springframework.jdbc.datasource.DataSourceTransactionManager;
//
//import javax.sql.DataSource;
//
//@Configuration
//@MapperScan(basePackages = "com.dyrj.wph.report.**.dao", sqlSessionTemplateRef = "wphSqlSessionTemplate")
//public class WphDataSourceConfig {
//    @Bean(name = "wphDataSource")
//    @ConfigurationProperties(prefix = "spring.datasource.wph")
//    public DataSource setDataSource() {
//        return DataSourceBuilder.create().build();
//    }
//
//    @Bean(name = "wphTransactionManager")
//    public DataSourceTransactionManager setTransactionManager(@Qualifier("wphDataSource") DataSource dataSource) {
//        return new DataSourceTransactionManager(dataSource);
//    }
//
//    @Bean(name = "wphSqlSessionFactory")
//    public SqlSessionFactory setSqlSessionFactory(@Qualifier("wphDataSource") DataSource dataSource) throws Exception {
//        SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
//        bean.setDataSource(dataSource);
//        bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath*:com/dyrj/report/**/mapper/wph/*.xml"));
//        return bean.getObject();
//    }
//
//    @Bean(name = "wphSqlSessionTemplate")
//    public SqlSessionTemplate setSqlSessionTemplate(@Qualifier("wphSqlSessionFactory") SqlSessionFactory sqlSessionFactory) throws Exception {
//        return new SqlSessionTemplate(sqlSessionFactory);
//    }
//}
